package huffman;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:
 * Date: 2024-07-07
 * Time: 15:25
 */
public class HTNode implements Comparable<HTNode> {
    int id;
    int weight;
    char code;
    int parent, lchild, rchild;

    public HTNode(int id) {
        this.id = id;
        this.weight = -1;
        this.code = '\0';
        this.parent = -1;
        this.lchild = -1;
        this.rchild = -1;
    }

    public HTNode(int id, int weight) {
        this.id = id;
        this.weight = weight;
        this.code = '\0';
        this.parent = -1;
        this.lchild = -1;
        this.rchild = -1;
    }

    public HTNode(int id, char code, int weight) {
        this.id = id;
        this.weight = weight;
        this.code = code;
        this.parent = -1;
        this.lchild = -1;
        this.rchild = -1;
    }

    public HTNode(int id, char code, int weight, int lchild, int rchild) {
        this.id = id;
        this.weight = weight;
        this.code = code;
        this.parent = -1;
        this.lchild = lchild;
        this.rchild = rchild;
    }

    public HTNode(int id, char code, int weight, int parent, int lchild, int rchild) {
        this.id = id;
        this.weight = weight;
        this.code = code;
        this.parent = parent;
        this.lchild = lchild;
        this.rchild = rchild;
    }

    public int compareTo(HTNode x) {
        if (x.weight < this.weight) {
            return 1;
        } else if (x.weight > this.weight) {
            return -1;
        }
        return 0;
    }

}